<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>lwIP: src/include/lwip/ip6_zone.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">lwIP
   &#160;<span id="projectnumber">2.1.2</span>
   </div>
   <div id="projectbrief">Lightweight IP stack</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('ip6__zone_8h.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#enum-members">Enumerations</a>  </div>
  <div class="headertitle">
<div class="title">ip6_zone.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ga2049167d1715b9a9cf2730e122c0d4fb"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ip6__zones.html#ga2049167d1715b9a9cf2730e122c0d4fb">IP6_NO_ZONE</a>&#160;&#160;&#160;0</td></tr>
<tr class="separator:ga2049167d1715b9a9cf2730e122c0d4fb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa090e54f632c8512a7991307e011c1b9"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ip6__zones.html#gaa090e54f632c8512a7991307e011c1b9">IPADDR6_ZONE_INIT</a>&#160;&#160;&#160;, <a class="el" href="group__ip6__zones.html#ga2049167d1715b9a9cf2730e122c0d4fb">IP6_NO_ZONE</a></td></tr>
<tr class="separator:gaa090e54f632c8512a7991307e011c1b9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaee83e12649fa9706857c9ad8f9ef8634"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ip6__zones.html#gaee83e12649fa9706857c9ad8f9ef8634">ip6_addr_zone</a>(ip6addr)&#160;&#160;&#160;((ip6addr)-&gt;zone)</td></tr>
<tr class="separator:gaee83e12649fa9706857c9ad8f9ef8634"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8727c081b6a80992881d481d0680db78"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ip6__zones.html#ga8727c081b6a80992881d481d0680db78">ip6_addr_has_zone</a>(ip6addr)&#160;&#160;&#160;(<a class="el" href="group__ip6__zones.html#gaee83e12649fa9706857c9ad8f9ef8634">ip6_addr_zone</a>(ip6addr) != <a class="el" href="group__ip6__zones.html#ga2049167d1715b9a9cf2730e122c0d4fb">IP6_NO_ZONE</a>)</td></tr>
<tr class="separator:ga8727c081b6a80992881d481d0680db78"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga213310b303dd050da7856d67da72abd6"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ip6__zones.html#ga213310b303dd050da7856d67da72abd6">ip6_addr_set_zone</a>(ip6addr,  zone_idx)&#160;&#160;&#160;((ip6addr)-&gt;zone = (zone_idx))</td></tr>
<tr class="separator:ga213310b303dd050da7856d67da72abd6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae0249db6cd2687f2dbc445e7778d37ad"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ip6__zones.html#gae0249db6cd2687f2dbc445e7778d37ad">ip6_addr_clear_zone</a>(ip6addr)&#160;&#160;&#160;((ip6addr)-&gt;zone = <a class="el" href="group__ip6__zones.html#ga2049167d1715b9a9cf2730e122c0d4fb">IP6_NO_ZONE</a>)</td></tr>
<tr class="separator:gae0249db6cd2687f2dbc445e7778d37ad"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga7347729485d837bcff85ae4731bbf5c4"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ip6__zones.html#ga7347729485d837bcff85ae4731bbf5c4">ip6_addr_copy_zone</a>(ip6addr1,  ip6addr2)&#160;&#160;&#160;((ip6addr1).zone = (ip6addr2).zone)</td></tr>
<tr class="separator:ga7347729485d837bcff85ae4731bbf5c4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaeead8379cc3fd4c257be0bb654994a8f"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ip6__zones.html#gaeead8379cc3fd4c257be0bb654994a8f">ip6_addr_equals_zone</a>(ip6addr,  zone_idx)&#160;&#160;&#160;((ip6addr)-&gt;zone == (zone_idx))</td></tr>
<tr class="separator:gaeead8379cc3fd4c257be0bb654994a8f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gacbb8e1a7505d9772181defa0e75b8da9"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ip6__zones.html#gacbb8e1a7505d9772181defa0e75b8da9">ip6_addr_cmp_zone</a>(ip6addr1,  ip6addr2)&#160;&#160;&#160;((ip6addr1)-&gt;zone == (ip6addr2)-&gt;zone)</td></tr>
<tr class="separator:gacbb8e1a7505d9772181defa0e75b8da9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae677a65970f4b667156b256dd9a4924b"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ip6__zones.html#gae677a65970f4b667156b256dd9a4924b">IPV6_CUSTOM_SCOPES</a>&#160;&#160;&#160;0</td></tr>
<tr class="separator:gae677a65970f4b667156b256dd9a4924b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa5332bb3b70c1a9acba1bea3ea0ecb90"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ip6__zones.html#gaa5332bb3b70c1a9acba1bea3ea0ecb90">ip6_addr_has_scope</a>(ip6addr,  type)</td></tr>
<tr class="separator:gaa5332bb3b70c1a9acba1bea3ea0ecb90"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1040a3d67498a1ef617bda8d9e0ba3a5"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ip6__zones.html#ga1040a3d67498a1ef617bda8d9e0ba3a5">ip6_addr_assign_zone</a>(ip6addr,  type,  <a class="el" href="structnetif.html">netif</a>)</td></tr>
<tr class="separator:ga1040a3d67498a1ef617bda8d9e0ba3a5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac3ec5f94e1cd62b1237efca3723dc06e"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ip6__zones.html#gac3ec5f94e1cd62b1237efca3723dc06e">ip6_addr_test_zone</a>(ip6addr,  <a class="el" href="structnetif.html">netif</a>)&#160;&#160;&#160;(<a class="el" href="group__ip6__zones.html#gaeead8379cc3fd4c257be0bb654994a8f">ip6_addr_equals_zone</a>((ip6addr), netif_get_index(<a class="el" href="structnetif.html">netif</a>)))</td></tr>
<tr class="separator:gac3ec5f94e1cd62b1237efca3723dc06e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad963bf3e9695ba898271e314975f5c97"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ip6__zones.html#gad963bf3e9695ba898271e314975f5c97">ip6_addr_lacks_zone</a>(ip6addr,  type)&#160;&#160;&#160;(!<a class="el" href="group__ip6__zones.html#ga8727c081b6a80992881d481d0680db78">ip6_addr_has_zone</a>(ip6addr) &amp;&amp; <a class="el" href="group__ip6__zones.html#gaa5332bb3b70c1a9acba1bea3ea0ecb90">ip6_addr_has_scope</a>((ip6addr), (type)))</td></tr>
<tr class="separator:gad963bf3e9695ba898271e314975f5c97"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac83f3e7c8d65d3c784bffc9dec29b70c"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ip6__zones.html#gac83f3e7c8d65d3c784bffc9dec29b70c">ip6_addr_select_zone</a>(dest,  src)</td></tr>
<tr class="separator:gac83f3e7c8d65d3c784bffc9dec29b70c"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:ga1993c4b6a297b6e92d80a9ce46ddedfe"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ip6__zones.html#ga1993c4b6a297b6e92d80a9ce46ddedfe">lwip_ipv6_scope_type</a> { <a class="el" href="group__ip6__zones.html#gga1993c4b6a297b6e92d80a9ce46ddedfeaddb1d298ce96cea5ccc8e1397443dbb8">IP6_UNKNOWN</a> = 0, 
<a class="el" href="group__ip6__zones.html#gga1993c4b6a297b6e92d80a9ce46ddedfeaacbcc65569837d437eea53c3bbb017b0">IP6_UNICAST</a> = 1, 
<a class="el" href="group__ip6__zones.html#gga1993c4b6a297b6e92d80a9ce46ddedfea70cda997b66f3e120e925c5a41904809">IP6_MULTICAST</a> = 2
 }</td></tr>
<tr class="separator:ga1993c4b6a297b6e92d80a9ce46ddedfe"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>IPv6 address scopes, zones, and scoping policy.</p>
<p>This header provides the means to implement support for IPv6 address scopes, as per RFC 4007. An address scope can be either global or more constrained. In lwIP, we say that an address "has a scope" or "is scoped" when its scope is constrained, in which case the address is meaningful only in a specific "zone." For unicast addresses, only link-local addresses have a scope; in that case, the scope is the link. For multicast addresses, there are various scopes defined by RFC 4007 and others. For any constrained scope, a system must establish a (potentially one-to-many) mapping between zones and local interfaces. For example, a link-local address is valid on only one link (its zone). That link may be attached to one or more local interfaces. The decisions on which scopes are constrained and the mapping between zones and interfaces is together what we refer to as the "scoping policy" - more on this in a bit.</p>
<p>In lwIP, each IPv6 address has an associated zone index. This zone index may be set to "no zone" (IP6_NO_ZONE, 0) or an actual zone. We say that an address "has a zone" or "is zoned" when its zone index is <em>not</em> set to "no
zone." In lwIP, in principle, each address should be "properly zoned," which means that if the address has a zone if and only if has a scope. As such, it is a rule that an unscoped (e.g., global) address must never have a zone. Even though one could argue that there is always one zone even for global scopes, this rule exists for implementation simplicity. Violation of the rule will trigger assertions or otherwise result in undesired behavior.</p>
<p>Backward compatibility prevents us from requiring that applications always provide properly zoned addresses. We do enforce the rule that the in the lwIP link layer (everything below netif-&gt;output_ip6() and in particular ND6) <em>all</em> addresses are properly zoned. Thus, on the output paths down the stack, various places deal with the case of addresses that lack a zone. Some of them are best-effort for efficiency (e.g. the PCB bind and connect API calls' attempts to add missing zones); ultimately the IPv6 output handler (<a class="el" href="ip6_8h.html#a58bd3c9ce332731fac82b89c77be4f56">ip6_output_if_src</a>) will set a zone if necessary.</p>
<p>Aside from dealing with scoped addresses lacking a zone, a proper IPv6 implementation must also ensure that a packet with a scoped source and/or destination address does not leave its zone. This is currently implemented in the input and forward functions. However, for output, these checks are deliberately omitted in order to keep the implementation lightweight. The routing algorithm in <a class="el" href="ip6_8h.html#a1153bd9e8c45847282105ab6379e6e70">ip6_route</a> will take decisions such that it will not cause zone violations unless the application sets bad addresses, though.</p>
<p>In terms of scoping policy, lwIP implements the default policy from RFC 4007 using macros in this file. This policy considers link-local unicast addresses and (only) interface-local and link-local multicast addresses as having a scope. For all these addresses, the zone is equal to the interface. As shown below in this file, it is possible to implement a custom policy. </p>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_b0856f6b0d80ccb263b2f415c91f9e17.html">include</a></li><li class="navelem"><a class="el" href="dir_4e6b3cf33a61b6caac9c8ac30c866f37.html">lwip</a></li><li class="navelem"><a class="el" href="ip6__zone_8h.html">ip6_zone.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
